package com.example.schoolhelp.util;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;

public class ImageFromAssets {

    public static Bitmap getAssetsImag(Context content, String fileName) {
        AssetManager assets = null;
        assets = content.getAssets();
        if ("".equals(fileName) || fileName == null) {
            return null;
        }
        //获取/assests/目录下的所有的文件
        try {
//			String[] list = assets.list("");
            InputStream is = assets.open(fileName);
            Bitmap bitmap = BitmapFactory.decodeStream(is);
            is.close();
            return bitmap;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }


}